<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>watch</title>
    <script src="../vue.global.js"></script>
    <style>
        .red{
            color:red;
        }
        .font-big{
            font-size: 50px;
        }
    </style>
</head>
<body>

<div id="App">

    <input type="text" name="user" ref="user" v-model="user.name" v-model="user.age"/>
    {{user.name}}
    {{user.age}}
</div>


<script>



    const app = Vue.createApp({

        data(){
            return {
                user:{
                    name:"jack",
                    age:10000
                }
            }
        },
        methods:{
            // getMsg(newValue,oldValue){
            //     console.log(newValue,oldValue);
            // }
            getMsg(newValue,oldValue){
                console.log(newValue.name,oldValue.name);
            },
            getMsg2(newValue,oldValue){
                console.log("2",newValue.name,oldValue.name);
            }
        },
        watch:{
            // msg(newValue,oldValue){
            //     console.log(newValue,oldValue);
            // }
            //msg:'getMsg'
            //'user.name':'getMsg
            user:[
                {
                    handler:'getMsg',
                    deep:true,//深度监听
                    immediate:false,
                },
                {
                    handler:'getMsg2',
                    deep:true,//深度监听
                }
            ]
        }
    });

    const vm =app.mount("#App");


</script>
</body>
</html>